﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
</head>
<body>
    <div>
        <div>授权中......</div>
    </div>
    <script src="js/Jquery3.6.js"></script>
    <script type="text/javascript">      
        //截取地址中的参数code，去请求accesstoken
        $(document).ready(function () {
            //利用地址中的code，去请求getAccessToken接口方法
            var code = getUrlParam('code');
            var shop_id = getUrlParam('shop_id');
            var main_account_id = getUrlParam('main_account_id');
            $.ajax({
                type: "Get",
                url: "/Shopee/GetAccessToken",
                data: { code: code, shop_id: shop_id, main_account_id: main_account_id},
                dataType: "json",
                success: function (data) {
                    $('#resText').empty();   //清空resText里面的所有内容
                    //显示授权成功
                },
                Error: function (error) {
                    //记录错误
                    //显示授权失败
                }
            });
        })

        function getUrlParam(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
            var r = window.location.search.substr(1).match(reg);  //匹配目标参数
            if (r != null) return unescape(r[2]); return null; //返回参数值
        }
    </script>
</body>
</html>